package com.nit.generate;

import com.nit.tools.loop.NitLoopTools;

import java.text.DecimalFormat;

/**
 * 经纬度 生成器
 *
 * @Auth: 逆天开源-逍遥哥哥
 * @link: 1715656022@qq.com
 * @Date: 2023-07-11
 */
public class NitPostionGenerator {
    private static double MIN_LON = 0.00;
    private static double MAX_LON = 180.00;
    private static double MIN_LAT = -90.00;
    private static double MAX_LAT = 90.00;

    public static void main(String[] args) {
        NitLoopTools.loop(100, () -> {
            String tmp = NitPostionGenerator.generate();
            System.out.println("随机经纬度:" + tmp + "<br>");
        });
    }

    public static String generate() {
//        纬度
        double latitude = MIN_LAT + (double) (Math.random() * ((MAX_LAT - MIN_LAT) + 1));
//        经度
        double longitude = MIN_LON + (double) (Math.random() * ((MAX_LON - MIN_LON) + 1));
        DecimalFormat df = new DecimalFormat("#.#####");
        return df.format(latitude) + "," + df.format(longitude);
    }


}
